function getorders() {
	$.ajax({
		url: 'http://localhost:3000/admin/userOrder',
		method: 'GET',
		async: false,
		data: { userId: sessionStorage.getItem('userid') },
		success: function (data) {
			$('#itemContainer')[0].innerHTML = '';
			for (var i = 0; i < data.data.length; i++) {
				var date = moment(data.data[i].systime).format('YYYY年MM月DD日 HH:mm:ss');

				$('#itemContainer')[0].innerHTML += `
        <table border="0" cellspacing="" cellpadding="" class="list animated wobble">
        <tbody>
          <tr class="order-info">
            <td colspan="8">
              <span style="margin-left: 20px;">订单编号&nbsp;:&nbsp;</span><i class="order-num">${data.data[i].id}</i>
              <span style="margin-left: 40px;">下单时间&nbsp;:&nbsp;</span><i class="order-num">
              ${date}
              </i>
            </td> 
                
        </tbody>
      </table>`;
				var cov = '';
				var mone = 0;
				for (var j = 0; j < data.data[i].goods.length; j++) {
					var lengths = data.data[i].goods.length;

					mone += data.data[i].goods[j].price * data.data[i].goods[j].num;
					console.log(mone);
					$('tbody')[i].innerHTML += `<tr class="order" style="margin-bottom: 10px;">           
        <td class="li1" style="text-align: left;" colspan="4">
          <a href="javascript:void(0)" onclick="datai(${data.data[i].goods[j].goodId})"><img src="http://localhost:3000/file_upload/${data.data[i].goods[j].cover}"></a>
          <div class="m-good-descript">
            <a href="javascript:void(0)" onclick="datai(${data.data[i].goods[j].goodId})">
              <p class="goods-descript">${data.data[i].goods[j].goodName}</p>
            </a>
          </div>
          <div class="li3"><span>￥${data.data[i].goods[j].price}</span></div>
          <div class="li4"><span>${data.data[i].goods[j].num}</span></div>
          <div class="li5"></div>
        </td>      
        <td class="li6" style="${j > 0 ? 'display:none' : ''}" rowspan="${j == 0 ? lengths : 1}">
        <div>
          <p style="${j > 0 ? 'display:none' : ''}" class="total-money">￥${data.data[i].total}</p>
        </div>
        </td>
          <td style="${j > 0 ? 'display:none' : ''}" class="li7" rowspan="${j == 0 ? lengths : 1}">
        <div>
        <span style="${j > 0 ? 'display:none' : ''}">${
						data.data[i].status == 1
							? '待付款'
							: data.data[i].status == 3
							? '已发货'
							: data.data[i].status == 4
							? '已完成'
							: data.data[i].paytype == 1
							? '已付款（微信）'
							: data.data[i].paytype == 2
							? '已付款（支付宝）'
							: '货到付款'
					}</span>
        </div>
        </td>
        <td class="li8" style="${j > 0 ? 'display:none' : ''}" rowspan="${j == 0 ? lengths : 1}">
        <div>
          <p>
          <a style="${data.data[i].status == 1 ? '' : 'display:none'}"  href="javascript:void(0)" onclick="topay(${data.data[i].id})"><span class="sta1 pay noSelect">确认付款</span></a>
          </p>
        </div>
        </td>
        </tr>`;
				}
			}
		}
	});
}
getorders();
function topay(id) {
	sessionStorage.setItem('oid', id);
	location.href = './pay.html';
}
